﻿using GN.Pay.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.TradeChannel.Gyb.Response
{
    /// <summary>
    /// 响应抽象
    /// </summary>
    [Serializable]
    public abstract class AResponse : AService
    {
        /// <summary>
        /// 解析 Plain 值
        /// </summary>
        /// <param name="plain"></param>
        /// <returns></returns>
        protected IDictionary<string, string> AnalyzePlain(string plain)
        {
            var dic = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
            if (plain != null)
            {
                string[] sw = plain.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string s in sw)
                {
                    var index = s.IndexOf("=");
                    if (index > 0)
                    {
                        string key = s.Substring(0, index).Trim();
                        if (s.Length > index + 1)
                        {
                            string value = s.Substring(index + 1).Trim();
                            dic[key] = value;
                        }
                    }
                }
            }
            return dic;
        }


       

    }
}
